/**
 *
 */
$(document)
    .ready(
        function() {
            $("form").submit(function() {
                return false;
            });

            var VAL = {
                EVT_USR :  $("#userId").text() ,

                T_FBPBISTOL : "FBPBISTOL",
                T_FBPMITEML : "FBPMITEML",
                T_FBPMDLDEF : "FBPMDLDEF",
                NORMAL : "0000000",
                DISABLED_ATTR : {
                    "disabled" : true
                },
                ENABLED_ATTR : {
                    "disabled" : false
                },
                ITEMFLG : "N",
                InsertFlg : "N"
            };

            var domObj = {
                $toolIdFk : $("#toolIdFk"),
                $repUnit : $("#repUnit"),
                $dataPat : $("#dataPat"),
                $mesIdFk : $("#mesIdFk"),
             /*   $mdlIdFk : $("#mdlIdFk"),*/

                //query dialog
                $toolIdFkTxt :$("#toolIdFkTxt"),
                $repUnitTxt :$("#repUnitTxt"),
                $dataPatTxt :$("#dataPatTxt"),
                $mesIdFkTxt :$("#mesIdFkTxt"),
                // $mdlIdFkTxt :$("#mdlIdFkTxt"),

                //add MItem
                $bisMItemDialog_dataGroupSel :$("#bisMItemDialog_dataGroupSel"),
                $bisMItemDialog_dataDsc :$("#bisMItemDialog_dataDsc"),
                $bisMItemDialog_dataType :$("#bisMItemDialog_dataType"),
                $bisMItemDialog_dataGroupSeq :$("#bisMItemDialog_dataGroupSeq"),
                $bisMItemDialog_dataAttr :$("#bisMItemDialog_dataAttr"),
                $bisMItemDialog_opiDataFlg :$("#bisMItemDialog_opiDataFlg"),
                $bisMItemDialog_specChkFlg :$("#bisMItemDialog_specChkFlg"),
                $bisMItemDialog_uSpec :$("#bisMItemDialog_uSpec"),
                $bisMItemDialog_lSpec :$("#bisMItemDialog_lSpec"),
                $bisMItemDialog_specChkTyp :$("#bisMItemDialog_specChkTyp"),

                buttons : {
                    $query_btn : $("#query_btn"),
                    $save_btn : $("#save_btn"),
                    $add_btn : $("#add_btn"),
                    //$update_btn : $("#update_btn"),
                    $del_btn : $("#del_btn"),
                    $clear_btn : $("#clear_btn"),
                    $rollback_btn : $("#rollback_btn"),
                    $copy_btn : $("#copy_btn"),
                    $import_btn 	: $("#import_btn"),
                    $select_btn    	: $("#select_btn"),
                    $download_btn  	: $("#download_btn"),
                    $export_btn : $("#export_btn"),

                    $add_bisMItem_btn : $("#add_bisMItem_btn"),
                    $upd_bisMItem_btn : $("#upd_bisMItem_btn"),
                    $del_bisMItem_btn : $("#del_bisMItem_btn"),
                    $insertbisMItem_btn : $("#insertbisMItem_btn"),

                    $queryBisMDialog_queryBtn : $("#queryBisMDialog_queryBtn"),
                    $bisMItemDialog_addPamItemBtn : $("#bisMItemDialog_addPamItemBtn")
                },

                grids : {
                    $bisMListGrd : $("#bisMListGrd"),
                    $bisMItemListGrd : $("#bisMItemListGrd")
                },
            };

            function initBisMLabelList() {
                domObj.grids.$bisMListGrd
                    .jqGrid({
                        url : "",
                        datatype : "local",
                        mtype : "POST",
                        height : 500,
                        width : $("#bisMListDiv").width() * 0.99,
                        autowidth : false,
                        shrinkToFit:false,
                        autoScroll: false,
                        scroll : true,
                        resizable : true,
                        loadonce : true,
                        viewrecords : true,
                        rownumbers : true,
                        rowNum : 20,
                        colModel : [ {
                            name : 'rep_unit',
                            index : 'rep_unit',
                            label : '上报类别',
                            width : 100
                        },
                            {
                                name : 'tool_id_fk',
                                index : 'tool_id_fk',
                                label : '设备代码',
                                width : 100
                            }, /*{
                                name : 'mdl_id_fk',
                                index : 'mdl_id_fk',
                                label : '产品代码',
                                width : 100
                            }, */{
                                name : 'data_pat',
                                index : 'data_pat',
                                label : '上报属性',
                                width : 90
                            }, {
                                name : 'mes_id_fk',
                                index : 'mes_id_fk',
                                label : '量测名称',
                                width : 100
                            }],

                        pager : "bisMListPg",
                        onSelectRow : function(rowId) {

                          /*  if(domObj.$toolIdFk.attr("disabled") != "disabled"){
                                showErrorDialog("", "目前处于编辑中，请勿进行查询操作");
                                return false;
                            }*/

                            var selRowId, rowData, iary, toolIdFk, rep_unit,data_pat,mes_id_fk,inObj, outObj;
                            rowData = domObj.grids.$bisMListGrd
                                .jqGrid("getRowData", rowId);
                            toolIdFk = rowData.tool_id_fk;
                            rep_unit = rowData.rep_unit;
                            data_pat = rowData.data_pat;
                            mes_id_fk = rowData.mes_id_fk;
                            var mdl_id_fk  = rowData.mdl_id_fk;

                            SelectDom.setSelect(domObj.$toolIdFk,toolIdFk);
                            SelectDom.setSelect(domObj.$repUnit,rep_unit);
                            SelectDom.setSelect(domObj.$dataPat,data_pat);
                            SelectDom.setSelect(domObj.$mesIdFk,mes_id_fk);
                            // SelectDom.setSelect(domObj.$mdlIdFk,mdl_id_fk);
                            unableFn();
                            $("#update_btn").attr(VAL.ENABLED_ATTR);

                            iary = {
                                tool_id_fk : toolIdFk,
                                rep_unit : rep_unit,
                                data_pat : data_pat,
                                mes_id_fk : mes_id_fk,
                                // mdl_id_fk : mdl_id_fk
                            }
                            inObj = {
                                trx_id : VAL.T_FBPMITEML,
                                action_flg : 'I',
                                iary : [iary]
                            };
                            outObj = comTrxSubSendPostJson(inObj);
                            if (outObj.rtn_code === VAL.NORMAL) {
                                setGridInfo(outObj.oaryB,"#bisMItemListGrd");
                            }
                        },
                        beforeSelectRow :function (id) {
                            if(VAL.ITEMFLG == 'Y'){
                                showErrorDialog("", "目前ITEM处于编辑中，请勿进行查询操作");
                                return false;
                            }
                            return true;
                        }
                    });
            };

            function initBisMItemList() {
                domObj.grids.$bisMItemListGrd
                    .jqGrid({
                        url : "",
                        datatype : "local",
                        mtype : "POST",
                        height : 340,
                        width : $("#bisMItemListDiv").width() * 0.99,
                        autowidth : false,
                        shrinkToFit:false,
                        autoScroll: false,
                        scroll : true,
                        resizable : true,
                        loadonce : true,
                        viewrecords : true,
                        rownumbers : true,
                        multiselect:true,
                        rowNum : 20,
                        colModel : [
                            {
                            name : 'data_group',
                            index : 'data_group',
                            label : '参数组名',
                            width : 140
                            }, {
                                name : 'data_dsc',
                                index : 'data_dsc',
                                label : '参数说明',
                                width : 160
                            },  {
                                name : 'data_type',
                                index : 'data_type',
                                label : '参数类型',
                                width : 160
                            }, {
                                name : 'data_group_seq',
                                index : 'data_group_seq',
                                label : '组内顺序',
                                width : 160
                            }, {
                                name : 'data_attr',
                                index : 'data_attr',
                                label : '参数属性',
                                width : 160
                            },
                            {
                                name : 'spec_chk_flg',
                                index : 'spec_chk_flg',
                                label : '规格限制',
                                width : 100
                            },  {
                                name : 'u_spec',
                                index : 'u_spec',
                                label : '上规格',
                                width : 160
                            },  {
                                name : 'l_spec',
                                index : 'l_spec',
                                label : '下规格',
                                width : 160
                            }, {
                                name : 'opi_data_flg',
                                index : 'opi_data_flg',
                                label : '是否上传',
                                width : 100
                            }, /* {
                                name : 'spec_chk_typ',
                                index : 'spec_chk_typ',
                                label : '规格标准',
                                width : 160,
                                hidden:true
                            }, */ ],

                        pager : "bisMItemListPg",
                    });
            };

            // 初始化下拉框
            var initSelectFnc = {
                // 1.初始化设备代码
                initToolId : function() {
                    var inObj,outObj;
                    inObj = {
                        trx_id : VAL.T_FBPBISTOL,
                        action_flg : 'L',
                        iary : [{}]
                    };
                    outObj = comTrxSubSendPostJson(inObj);
                    if (outObj.rtn_code == VAL.NORMAL) {
                        SelectDom.initWithSpace(domObj.$toolIdFk);
                        tblCnt = outObj.tbl_cnt;
                        for (i = 0; i < tblCnt; i++) {
                            if(tblCnt > 1){
                                oary = outObj.oary[i];
                            }else{
                                oary = outObj.oary[0];
                            }
                            SelectDom.addSelect(domObj.$toolIdFk, oary.tool_id,oary.tool_id+":"+oary.tool_dsc);
                        }
                    }
                },

                //初始化产品下拉
              /*  initMdlIdFk : function(){
                   var inObj = {
                        trx_id : VAL.T_FBPMDLDEF,
                        action_flg : "Q",
                        iary : [{}]
                    };

                   var outObj = comTrxSubSendPostJson(inObj);
                   var  tblCnt = outObj.tbl_cnt;
                   if(outObj.rtn_code = "0000000"){
                       var warp = document.createDocumentFragment();
                       for (i = 0; i < tblCnt; i++) {
                           var option = document.createElement("option");
                           option.value = outObj.oary[i].mdl_id;
                           option.text = outObj.oary[i].mdl_id;
                           warp.appendChild(option);
                       }
                       domObj.$mdlIdFk.append(warp);
                   }

                },*/

                // 2.初始化上报类别
                initRepUnit : function() {
                    //SelectDom.initWithSpace(domObj.$repUnit);
                    addValueByDataCateFnc("#repUnit", "MLRU", "data_ext");
                },

                // 3. 上报属性
                initDataPat : function() {
                    comAddValueByDataCateFnc("#dataPat", "MLDP", "data_ext","data_desc");
                },

                // 4.量测名称
                initMesIdFk : function() {
                    comAddValueByDataCateFnc("#mesIdFk", "MLID", "data_ext","data_desc");
                    //addValueByDataCateFnc("#mesIdFk", "MLGP", "data_ext");
                    //addValueByDataCateFnc("#mesIdFk", "MLGP", "data_id");
                },

                //dialog
                //参数名称 data_group
                initDataId : function(){
                    addValueByDataCateFnc("#bisMItemDialog_dataGroupSel", "MLGP", "data_ext");
                },

                //参数属性
                initDataAttr : function() {
                    SelectDom.addSelect(domObj.$bisMItemDialog_dataAttr,"F","F");//float
                    SelectDom.addSelect(domObj.$bisMItemDialog_dataAttr,"C","C");//char
                    //SelectDom.addSelect(domObj.$bisMItemDialog_dataAttr,"B","B");
                },

                //规格标准
                initSpecChkTyp : function() {
                    var warp, option;
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_specChkTyp);
                    warp = document.createDocumentFragment();
                    for (i = 0; i < 3; i++) {
                        option = document.createElement("option");
                        option.value = i;
                        option.text = i;
                        warp.appendChild(option);
                    }
                    domObj.$bisMItemDialog_specChkTyp.append(warp);
                }
            };

            function initSelect() {
                initSelectFnc.initToolId();
                initSelectFnc.initRepUnit();
                initSelectFnc.initDataPat();
                initSelectFnc.initMesIdFk();
                // initSelectFnc.initMdlIdFk();
            };

            function initDialogSelect(){
                initSelectFnc.initDataId();
                initSelectFnc.initDataAttr();
                initSelectFnc.initSpecChkTyp();
                domObj.$bisMItemDialog_dataGroupSel.change(function () {
                    //addValueByDataCateFnc("#bisMItemDialog_dataGroupSel", "MLID", "data_item");
                    var dataGroupSel = domObj.$bisMItemDialog_dataGroupSel.val();
                    var iary = {
                        data_cate : 'MLGP',
                        data_ext :dataGroupSel
                    };
                    var inObj = {
                        trx_id      : 'FBPBISDAT' ,
                        action_flg : 'Q'        ,
                        iary        : [iary]
                    };
                    outObj = comTrxSubSendPostJson(inObj);
                    if (outObj.rtn_code === VAL.NORMAL) {
                        domObj.$bisMItemDialog_dataDsc.val(outObj.oary[0].data_desc);
                        domObj.$bisMItemDialog_dataType.val(outObj.oary[0].ext_2);
                    }
                });
            };

            var buttonFnc = {
                addFnc : function() {
                    VAL.InsertFlg = 'N';
                    if(VAL.ITEMFLG == 'Y'){
                        showErrorDialog("", "目前ITEM处于编辑中，请勿进行查询操作");
                        return false;
                    }
                    SelectDom.initWithSpace(domObj.$toolIdFk);
                    SelectDom.initWithSpace(domObj.$repUnit);
                    SelectDom.initWithSpace(domObj.$dataPat);
                    SelectDom.initWithSpace(domObj.$mesIdFk);
                    // SelectDom.initWithSpace(domObj.$mdlIdFk);
                    domObj.grids.$bisMItemListGrd.jqGrid('clearGridData');
                    initSelect();
                    enableFn();
                    $("#update_btn").attr(VAL.DISABLED_ATTR);
                },

                queryFnc : function() {
                    VAL.InsertFlg = 'N';
                   /* if(domObj.$toolIdFk.attr("disabled") != "disabled"){
                        showErrorDialog("", "目前处于编辑中，请勿进行查询操作");
                        return false;
                    }*/
                    if(VAL.ITEMFLG == 'Y'){
                        showErrorDialog("", "目前ITEM处于编辑中，请勿进行查询操作");
                        return false;
                    }

                    $('#queryBisMDialog').modal({
                        backdrop : 'static',
                        keyboard : false,
                        show : false
                    });

                    $('#queryBisMDialog').unbind('shown.bs.modal');
                    $("#queryBisMDialog_queryBtn").unbind('click');
                    $('#queryBisMDialog').bind('shown.bs.modal');
                    $('#queryBisMDialog').modal("show");
                    //模态框查询按钮绑定查询函数
                    $("#queryBisMDialog_queryBtn").bind('click', queryDialog.queryFnc);
                    $("#queryBisMDialog input").attr(VAL.ENABLED_ATTR);
                    $('#queryBisMDialog input').val("");
                    $("#update_btn").attr(VAL.ENABLED_ATTR);
                },

                saveFnc : function() {
                    VAL.ITEMFLG = 'N';
                    VAL.InsertFlg ='N';
                    var actionFlg, inObj, outObj, iary, newRowId, rowIds, selRowId;
                    // 可编辑说明为新增，不可编辑说明为修改
                    actionFlg = domObj.$toolIdFk.attr("disabled") === "disabled" ? "U"
                        : "A";
                    var toolIdFk = domObj.$toolIdFk.val();
                    if(toolIdFk == ""){
                        showErrorDialog("", "请先新增或修改后再保存!");
                        return false;
                    }
                    var repUnit = domObj.$repUnit.val();
                    var dataPat = domObj.$dataPat.val();
                    var mesIdFk = domObj.$mesIdFk.val();
                    // var mdlIdFk = domObj.$mdlIdFk.val();
                    if (!toolIdFk) {
                        showErrorDialog("", "设备代码不能为空,请选择！");
                        return false;
                    }

                    if (!repUnit) {
                        showErrorDialog("", "上报类别不能为空,请选择！");
                        return false;
                    }

                    if (!dataPat) {
                        showErrorDialog("", "上报属性不能为空,请选择！");
                        return false;
                    }

                    if (!mesIdFk) {
                        showErrorDialog("", "量测名称不能为空,请选择！");
                        return false;
                    }

                    // if (!mdlIdFk) {
                    //     showErrorDialog("", "产品代码不能为空,请选择！");
                    //     return false;
                    // }

                    var item = domObj.grids.$bisMItemListGrd.getRowData();

                    // if(VAL.sortFlg == "Y"){
                    //     //判断相同组的item有无重复datagroupseq 升序
                    //     item.sort(function(a, b){
                    //         if (a.data_group_seq === b.data_group_seq) {
                    //             var j = parseInt(a.data_group.substring(2));
                    //             var i = parseInt(b.data_group.substring(2));
                    //             return j - i;
                    //         } else {
                    //             return a.data_group_seq - b.data_group_seq;
                    //         }
                    //     });
                    // }

                    var iaryB = [];
                    for(var i = 0; i < item.length;i++){
                        var data_type;
                        if(item[i].data_type == "设备状态" || item[i].data_type == "02"){
                            data_type ="02";
                        }else if(item[i].data_type == "制程数据" || item[i].data_type == "03"){
                            data_type ="03";
                        }else if(item[i].data_type == "设备警报" || item[i].data_type == "01"){
                            data_type ="01";
                        }

                        iaryB.push({
                            tool_id_fk : toolIdFk,
                            // mdl_id_fk : mdlIdFk,
                            rep_unit_fk : repUnit,
                            data_pat_fk : dataPat,
                            mes_id_fk : mesIdFk,
                            data_group : item[i].data_group,
                            data_dsc : item[i].data_dsc,
                            data_id : i+1, //从1开始
                            data_seq : i+1,
                            data_group_seq : item[i].data_group_seq,
                            data_type : data_type,
                            data_attr : item[i].data_attr,
                            spec_chk_flg : item[i].spec_chk_flg,
                            u_spec : item[i].u_spec,
                            l_spec : item[i].l_spec,
                            opi_data_flg : item[i].opi_data_flg,
                            spec_chk_typ : item[i].spec_chk_typ,
                        });
                    };

                    iary = {
                        tool_id_fk : toolIdFk,
                        rep_unit : repUnit,
                        data_pat : dataPat,
                        mes_id_fk : mesIdFk,
                        // mdl_id_fk : mdlIdFk
                    };
                    // 输给后台的数据
                    inObj = {
                        trx_id : VAL.T_FBPMITEML,
                        action_flg : actionFlg,
                        iary : [iary],
                        iaryB : iaryB,
                        evt_usr : VAL.EVT_USR
                    };
                    outObj = comTrxSubSendPostJson(inObj);
                    if (outObj.rtn_code === VAL.NORMAL) {
                        if (actionFlg == "A") {
                            // comfunction有
                            newRowId = getGridNewRowID("#bisMListGrd");
                            domObj.grids.$bisMListGrd.jqGrid(
                                "addRowData", newRowId,
                                outObj.oary[0]);
                            domObj.grids.$bisMListGrd.setSelection(newRowId, true);
                            showSuccessDialog("数据信息新建成功");
                            unableFn();
                            $("#update_btn").attr(VAL.ENABLED_ATTR);
                        } else if (actionFlg == "U") {
                            selRowId = domObj.grids.$bisMListGrd
                                .jqGrid("getGridParam", "selrow");
                            domObj.grids.$bisMListGrd.jqGrid(
                                "setRowData", selRowId,
                                outObj.oary[0]);
                            showSuccessDialog("数据信息更新成功");
                            unableFn();
                        }
                    }
                },

                updateFnc : function() {
                    VAL.InsertFlg ='N';
                    var selRowId, rowData, iary, inObj, outObj, woStat;
                    selRowId = domObj.grids.$bisMListGrd.jqGrid(
                        "getGridParam", "selrow");
                    if (!selRowId) {
                        showErrorDialog("", "请选择需要修改的数据信息");
                        return false;
                    }
                    enableFn();
                    domObj.$toolIdFk.attr(VAL.DISABLED_ATTR);
                },

                copy_func:function(){
                    if(domObj.$toolIdFk.attr("disabled") != "disabled"){
                        showErrorDialog("", "目前处于编辑中，请勿进行查询操作");
                        return false;
                    }
                    if(VAL.ITEMFLG == 'Y'){
                        showErrorDialog("", "目前ITEM处于编辑中，请勿进行查询操作");
                        return false;
                    }
                    var selRowId = domObj.grids.$bisMListGrd.jqGrid("getGridParam","selrow");
                    if (!selRowId) {
                        showErrorDialog("", "请选择需要复制的数据信息");
                        return false;
                    }
                    $("#pamConditionForm input").attr(VAL.ENABLED_ATTR);
                    $("#pamConditionForm select").attr(VAL.ENABLED_ATTR);
                },

                delFnc : function() {
                    VAL.InsertFlg ='N'
                    if(domObj.$toolIdFk.attr("disabled") != "disabled"){
                        showErrorDialog("", "目前处于编辑中，请勿进行查询操作");
                        return false;
                    }
                    if(VAL.ITEMFLG == 'Y'){
                        showErrorDialog("", "目前ITEM处于编辑中，请勿进行查询操作");
                        return false;
                    }
                    var selRowId, rowData, iary, inObj, outObj;
                    // 获得选中的行ID
                    selRowId = domObj.grids.$bisMListGrd.jqGrid(
                        "getGridParam", "selrow");
                    if (!selRowId) {
                        showErrorDialog("", "请选择需要删除的数据信息！");
                        return false;
                    }
                    // 删除按钮绑定删除事件
                    $("#del_btn")
                        .showCallBackWarnningDialog(
                            {
                                errMsg : "是否删除该数据信息,请确认!!!!",
                                callbackFn : function(data) {
                                    if (data.result == true) {
                                        // 获得选中行的数据
                                        rowData = domObj.grids.$bisMListGrd
                                            .jqGrid(
                                                "getRowData",
                                                selRowId);
                                        iary = {
                                            tool_id_fk : rowData.tool_id_fk,
                                            rep_unit : rowData.rep_unit,
                                            data_pat : rowData.data_pat,
                                            mes_id_fk : rowData.mes_id_fk,
                                            mdl_id_fk : rowData.mdl_id_fk
                                        };
                                        inObj = {
                                            trx_id : VAL.T_FBPMITEML,
                                            action_flg : "D",
                                            iary : [iary]
                                        };
                                        outObj = comTrxSubSendPostJson(inObj);
                                        if (outObj.rtn_code === VAL.NORMAL) {
                                            showSuccessDialog("删除数据信息成功");
                                            domObj.grids.$bisMListGrd
                                                .jqGrid(
                                                    "delRowData",
                                                    selRowId);
                                            SelectDom.initWithSpace(domObj.$toolIdFk);
                                            SelectDom.initWithSpace(domObj.$repUnit);
                                            SelectDom.initWithSpace(domObj.$dataPat);
                                            SelectDom.initWithSpace(domObj.$mesIdFk);
                                            // SelectDom.initWithSpace(domObj.$mdlIdFk);
                                            $("#bisMItemListGrd").jqGrid('clearGridData');
                                            //enableFn();
                                            $("select").attr(VAL.DISABLED_ATTR);
                                            $("#update_btn").attr(VAL.ENABLED_ATTR);
                                        }
                                    }
                                }
                            });
                },
                rollback_func : function(){
                    VAL.InsertFlg ='N';
                    pageInit();
                    queryDialog.queryFnc();
                    $("#bisMItemListGrd").jqGrid('clearGridData');
                },

                clearFnc : function() {
                    VAL.InsertFlg ='N';
                    SelectDom.initWithSpace(domObj.$toolIdFk);
                    SelectDom.initWithSpace(domObj.$repUnit);
                    SelectDom.initWithSpace(domObj.$dataPat);
                    SelectDom.initWithSpace(domObj.$mesIdFk);
                    // SelectDom.initWithSpace(domObj.$mdlIdFk);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataGroupSel);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataAttr);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_specChkTyp);
                    //initSelect();
                    initDialogSelect();
                    $("#bisMListGrd").jqGrid('clearGridData');
                    $("#bisMItemListGrd").jqGrid('clearGridData');
                    //enableFn();
                    $("select").attr(VAL.DISABLED_ATTR);
                    $("#update_btn").attr(VAL.ENABLED_ATTR);
                },

                //TODO 导入ITEM项 excel
                selectFileFunc  : function(){
                    domObj.buttons.$select_btn.click();
                },

                uploadFnc  : function (obj) {
                    //清空jqgrid里面的数据
                    domObj.grids.$bisMItemListGrd.jqGrid("clearGridData");
                    var crr_query="N";
                    /*
                     FileReader共有4种读取方法：
                     1.readAsArrayBuffer(file)：将文件读取为ArrayBuffer。
                     2.readAsBinaryString(file)：将文件读取为二进制字符串
                     3.readAsDataURL(file)：将文件读取为Data URL
                     4.readAsText(file, [encoding])：将文件读取为文本，encoding缺省值为'UTF-8'
                     */
                    var wb;//读取完成的数据
                    var rABS = true; //是否将文件读取为二进制字符串
                    if(!obj.files) {
                        return;
                    }
                    var fileName = obj.value;
                    if(fileName.length > 1 && fileName ) {
                        var ldot = fileName.lastIndexOf(".");
                        var type = fileName.substring(ldot + 1);
                        if(!(type=="xlsx"||type=="xls")) {
                            showErrorDialog("", "只能导入excel文件");
                            return;
                        }
                    }
                    var f = obj.files[0];
                    var reader = new FileReader();
                    reader.onload = function(e) {
                        var data = e.target.result;
                        if(rABS) {
                            wb = XLSX.read(btoa(fixdata(data)), {//手动转化
                                type: 'base64'
                            });
                        } else {
                            wb = XLSX.read(data, {
                                type: 'binary'
                            });
                        }
                        //wb.SheetNames[0]是获取Sheets中第一个Sheet的名字
                        //wb.Sheets[Sheet名]获取第一个Sheet的数据
                        var data = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
                        data = JSON.parse(JSON.stringify(data).replace(/参数组名/g,"data_group"));
                        data = JSON.parse(JSON.stringify(data).replace(/参数类型/g,"data_type"));
                        data = JSON.parse(JSON.stringify(data).replace(/参数说明/g,"data_dsc"));
                        data = JSON.parse(JSON.stringify(data).replace(/组内顺序/g,"data_group_seq"));
                        data = JSON.parse(JSON.stringify(data).replace(/参数属性/g,"data_attr"));
                        data = JSON.parse(JSON.stringify(data).replace(/是否上传/g,"opi_data_flg"));
                        data = JSON.parse(JSON.stringify(data).replace(/规格限制/g,"spec_chk_flg"));
                        data = JSON.parse(JSON.stringify(data).replace(/上规格/g,"u_spec"));
                        data = JSON.parse(JSON.stringify(data).replace(/下规格/g,"l_spec"));
                        setGridInfo(data, domObj.grids.$bisMItemListGrd);
                    };
                    if(rABS) {
                        reader.readAsArrayBuffer(f);
                    } else {
                        reader.readAsBinaryString(f);
                    }
                    function fixdata(data) { //文件流转BinaryString
                        var o = "", l = 0, w = 10240;
                        for(; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
                        o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
                        return o;
                    }
                },
                
                //TODO 下载ITEM项 excel模板
                downloadTempFun: function () {
                    if ($("#downForm").length > 0) {
                        $("#downForm").remove();
                    }
                    var str = '<form id="downForm" action="download.do" method="post">';
                    str = str + '<input type="hidden" name="fileName" id= "fileName" />';
                    str = str + "</form>";
                    $(str).appendTo("body");
                    $("#fileName").val("6A00.xlsx");
                    $("#downForm").submit();
                },

                exportFunc : function(){
                    exportExcel("#bisMItemListGrd");
                },

            };

            //spec_chk_flg Y/N
            domObj.$bisMItemDialog_specChkFlg.click(function (){
                if(domObj.$bisMItemDialog_specChkFlg.prop('checked')){
                    //规格disabled
                    domObj.$bisMItemDialog_lSpec.attr(VAL.ENABLED_ATTR);
                    domObj.$bisMItemDialog_uSpec.attr(VAL.ENABLED_ATTR);
                    domObj.$bisMItemDialog_specChkTyp.attr(VAL.ENABLED_ATTR);
                }else{
                    //初始化空值
                    domObj.$bisMItemDialog_lSpec.val("");
                    domObj.$bisMItemDialog_uSpec.val("");
                    SelectDom.setSelect(domObj.$bisMItemDialog_specChkTyp,"","");
                    domObj.$bisMItemDialog_lSpec.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_uSpec.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_specChkTyp.attr(VAL.DISABLED_ATTR);
                }
            });

            var itemButtonFnc ={
                itemAddFnc : function (){
                    VAL.ITEMFLG = 'Y';
                    var selRowId = domObj.grids.$bisMListGrd.jqGrid(
                        "getGridParam", "selrow");
                    if (!selRowId) {
                        showErrorDialog("", "请先确认数据信息，再新增参数！");
                        return false;
                    }

                    $('#bisMItemDialog').modal({
                        backdrop : 'static',
                        keyboard : false,
                        show : false
                    });

                    $('#bisMItemDialog').unbind('shown.bs.modal');
                    $("#bisMItemDialog_addPamItemBtn").unbind('click');
                    $('#bisMItemDialog').bind('shown.bs.modal');
                    $('#bisMItemDialog').modal("show");
                    //模态框查询按钮绑定查询函数
                    $("#bisMItemDialog_addPamItemBtn").bind('click', itemDialog.addOrUpdateFnc);
                    $("#bisMItemDialog input").attr(VAL.ENABLED_ATTR);
                    $("#bisMItemDialog select").attr(VAL.ENABLED_ATTR);
                    $('#bisMItemDialog input').val("");
                    $("#update_btn").attr(VAL.ENABLED_ATTR);
                    domObj.$bisMItemDialog_dataDsc.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_dataType.attr(VAL.DISABLED_ATTR);
                    //组内顺序
					/* var rowDatas = domObj.grids.$bisMItemListGrd.getRowData();
					 domObj.$bisMItemDialog_dataGroupSeq.val(rowDatas.length);
					 domObj.$bisMItemDialog_dataGroupSeq.attr(VAL.DISABLED_ATTR);
					 */
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataGroupSel);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataAttr);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_specChkTyp);
                    initDialogSelect();
                    domObj.$bisMItemDialog_lSpec.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_uSpec.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_specChkTyp.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_specChkFlg.prop('checked',false);
                    domObj.$bisMItemDialog_opiDataFlg.prop('checked',false);
                },

                itemUpdateFnc : function (){
                    VAL.ITEMFLG = 'Y';
                    VAL.InsertFlg = 'N';
                    var selRowId,rowData;
                    selRowId = domObj.grids.$bisMItemListGrd.jqGrid("getGridParam","selrow");
                    if(selRowId == null){
                        showErrorDialog("", "请先选择item信息!");
                        return false;
                    }
                    $('#bisMItemDialog').modal({
                        backdrop : 'static',
                        keyboard : false,
                        show : false
                    });

                    $("#bisMItemDialog").unbind('shown.bs.modal');
                    $("#bisMItemDialog_addPamItemBtn").unbind('click');
                    $("#bisMItemDialog").bind('shown.bs.modal');
                    $("#bisMItemDialog").modal("show");
                    $("#bisMItemDialog input").attr(VAL.ENABLED_ATTR);
                    $("#bisMItemDialog select").attr(VAL.ENABLED_ATTR);
                    $("#bisMItemDialog_dataGroupSel").attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_dataDsc.attr(VAL.DISABLED_ATTR);
                    domObj.$bisMItemDialog_dataType.attr(VAL.DISABLED_ATTR);
                    //初始化select
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataGroupSel);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_dataAttr);
                    SelectDom.initWithSpace(domObj.$bisMItemDialog_specChkTyp);
                    initDialogSelect();

                    rowData = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",selRowId);
                    SelectDom.setSelect(domObj.$bisMItemDialog_dataAttr,rowData.data_attr,rowData.data_attr);
                    SelectDom.setSelect(domObj.$bisMItemDialog_specChkTyp,rowData.spec_chk_typ,rowData.spec_chk_typ);
                    SelectDom.setSelect(domObj.$bisMItemDialog_dataGroupSel,rowData.data_group,rowData.data_group);
                    domObj.$bisMItemDialog_dataDsc.val(rowData.data_dsc);
                    domObj.$bisMItemDialog_dataType.val(rowData.data_type);
                    domObj.$bisMItemDialog_dataGroupSeq.val(rowData.data_group_seq);
                    domObj.$bisMItemDialog_dataAttr.val(rowData.data_attr);
                    if(rowData.spec_chk_flg == 'Y'){
                        domObj.$bisMItemDialog_specChkFlg.prop('checked',true);
                    }else{
                        domObj.$bisMItemDialog_specChkFlg.prop('checked',false);
                        domObj.$bisMItemDialog_uSpec.attr(VAL.DISABLED_ATTR);
                        domObj.$bisMItemDialog_lSpec.attr(VAL.DISABLED_ATTR);
                        domObj.$bisMItemDialog_specChkTyp.attr(VAL.DISABLED_ATTR);
                    }
                    if(rowData.opi_data_flg == 'Y'){
                        domObj.$bisMItemDialog_opiDataFlg.prop('checked',true);
                    }else{
                        domObj.$bisMItemDialog_opiDataFlg.prop('checked',false);
                    }
                    domObj.$bisMItemDialog_uSpec.val(rowData.u_spec);
                    domObj.$bisMItemDialog_lSpec.val(rowData.l_spec);
                    //模态框查询按钮绑定查询函数
                    $("#bisMItemDialog_addPamItemBtn").bind('click', itemDialog.addOrUpdateFnc);
                },

                itemDeleteFnc : function (){
                    var selRowId,selRowId2,rowData,rowData2,inObj, outObj;
                    var iaryB={};
                    VAL.ITEMFLG = 'Y';
                    VAL.InsertFlg ='N';
                    //判断有没有选中pamListGrd表格行
                    // selRowId = domObj.grids.$bisMItemListGrd.jqGrid("getGridParam","selrow");
                    // if(selRowId == null){
                    //     showErrorDialog("", "请先选择item信息!");
                    //     return false;
                    // }
                    var ids = domObj.grids.$bisMItemListGrd.jqGrid('getGridParam','selarrrow');
                    if (!ids) {
                        showErrorDialog("", "请选择需要删除的数据信息！");
                        return false;
                    }

                    //删除按钮绑定删除事件
                    $("#delete_port_btn").showCallBackWarnningDialog({
                        errMsg : "是否删除该Item信息,请确认!!!!",
                        callbackFn : function(data) {
                            if (data.result == true) {
                                showSuccessDialog("删除该Item信息成功,请点击保存！");
                                var length = ids.length;
                                for(var i = 0; i < length ; i++){
                                    domObj.grids.$bisMItemListGrd.jqGrid(
                                        "delRowData", ids[0]);
                                }
                                //获得选中行的数据
								/*selRowId2 = domObj.grids.$bisMListGrd.jqGrid("getGridParam","selrow");
								 rowData = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",selRowId);
								 rowData2 =domObj.grids.$bisMListGrd.jqGrid("getRowData",selRowId2);
								 iaryB = {
								 tool_id_fk : rowData2.tool_id_fk,
								 rep_unit_fk: rowData2.rep_unit,
								 data_pat_fk: rowData2.data_pat,
								 mes_id_fk: rowData2.mes_id_fk,
								 data_id: rowData.data_id
								 }

								 inObj = {
								 trx_id : VAL.T_FBPMITEML,
								 action_flg : "M",
								 iaryB : [iaryB]
								 };
								 outObj = comTrxSubSendPostJson(inObj);
								 if (outObj.rtn_code === VAL.NORMAL) {
								 showSuccessDialog("删除该Item信息成功");
								 domObj.grids.$bisMItemListGrd.jqGrid(
								 "delRowData", selRowId);
								 }*/
                            }
                        }
                    });
                }
            };


            function insertItemFnc(){
                var rowId = $("#bisMItemListGrd").jqGrid("getGridParam","selrow");
                var ind= $("#bisMItemListGrd").getInd(rowId);
                var newInd = ind == 1 ? 1 : ind -1;
                VAL.InsertFlg = 'I';
                itemButtonFnc.itemAddFnc();
            }

            var queryDialog = {
                queryFnc : function (){
                    var toolIdFk, repUnit, dataPat, mesIdFk,iary, inObj, outObj;
                    toolIdFk = domObj.$toolIdFkTxt.val();
                    repUnit = domObj.$repUnitTxt.val();
                    dataPat = domObj.$dataPatTxt.val();
                    mesIdFk = domObj.$mesIdFkTxt.val();
                    // var mdlIdFk = domObj.$mdlIdFkTxt.val();

                    iary = {
                        tool_id_fk : toolIdFk,
                        rep_unit : repUnit,
                        data_pat : dataPat,
                        mes_id_fk : mesIdFk,
                        // mdl_id_fk : mdlIdFk
                    };
                    inObj = {
                        trx_id : VAL.T_FBPMITEML,
                        action_flg : "Q",
                        iary : [ iary ],
                        evt_usr : VAL.EVT_USR,
                    };
                    outObj = comTrxSubSendPostJson(inObj);
                    if (outObj.rtn_code === VAL.NORMAL) {
                        setGridInfo(outObj.oary, "#bisMListGrd ");
                        $('#queryBisMDialog').modal("hide");
                    }
                }
            };

            //jqGrid相关函数
            function getAddRowID($grid) {
                var rowIds = $grid.jqGrid("getDataIDs");
                return rowIds.length > 0 ? parseInt(rowIds[rowIds.length - 1]) + 1 : "1";
            }

            var itemDialog = {
                addOrUpdateFnc : function (){
                    var  inObj, outObj, actionFlg,oary, tblCnt,newRowId,selRowId;
                    actionFlg = domObj.$bisMItemDialog_dataGroupSel.attr("disabled") === "disabled"
                        ? "U"
                        : "A";
                    var dataGroup = domObj.$bisMItemDialog_dataGroupSel.val();
                    var dataDsc = domObj.$bisMItemDialog_dataDsc.val();
                    var dataType = domObj.$bisMItemDialog_dataType.val();
                    var dataGroupSeq = domObj.$bisMItemDialog_dataGroupSeq.val();
                    var dataAttr = domObj.$bisMItemDialog_dataAttr.val();
                    if(!dataGroup){
                        showErrorDialog("","参数名称不能为空！请输入！");
                        return false;
                    }
                    if(!dataGroupSeq){
                        showErrorDialog("","组内顺序不能为空！请输入！");
                        return false;
                    }
                    if(!dataAttr){
                        showErrorDialog("","参数属性不能为空！请选择！")
                        return false;
                    }

                    var dataAttr = domObj.$bisMItemDialog_dataAttr.val();
                    var specChkFlg;
                    if(domObj.$bisMItemDialog_specChkFlg.prop('checked')){
                        specChkFlg = 'Y';
                    }else{
                        specChkFlg = 'N';
                    };
                    var opiDataFlg;
                    if(domObj.$bisMItemDialog_opiDataFlg.prop('checked')){
                        opiDataFlg = 'Y';
                    }else{
                        opiDataFlg = 'N';
                    }
                    var uSpec = domObj.$bisMItemDialog_uSpec.val();
                    var lSpec = domObj.$bisMItemDialog_lSpec.val();
                    var specChkTyp = domObj.$bisMItemDialog_specChkTyp.val();

                    if(actionFlg =="A"){
                        var dataIds = domObj.grids.$bisMItemListGrd.jqGrid("getDataIDs");
                        var dataGroupSeq = domObj.$bisMItemDialog_dataGroupSeq.val();//组内顺序
                        //查询出已有的最大的datagroup
                        var dataGroupSeqList = new Array();
                        for(var i = 0 ; i < dataIds.length ; i++){
                            var dataGroupS = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",dataIds[i]);
                            if(dataGroupS.data_group === dataGroup){
                                dataGroupSeqList.push(dataGroupS.data_group_seq);
                            }
                        }
                        var dataGroupSeqMax;
                        if(dataGroupSeqList.length > 0){
                            dataGroupSeqMax = Math.max.apply(null, dataGroupSeqList);
                        }else {
                            dataGroupSeqMax = 0;
                        }
                        var dataLength = parseInt(dataGroupSeq);
                        if(VAL.InsertFlg === 'I'){
                            for(var i = 0 ; i < dataIds.length ; i++){
                                var dataGroupS = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",dataIds[i]);
                                if((dataGroupS.data_group === dataGroup) && (dataGroupS.data_group_seq === dataGroupSeq)){
                                    showErrorDialog("","该参数组已存在相同组内顺序，请重新选择！");
                                    return false;
                                }
                            }

                            var rowId = $("#bisMItemListGrd").jqGrid("getGridParam","selrow");
                            if(lSpec!=""&&uSpec!=""){
                                if(parseFloat(uSpec,10) < parseFloat(lSpec,10)){
                                    showErrorDialog("","参数的上限不能小于下限！");
                                    return false;
                                }
                            }
                            domObj.grids.$bisMItemListGrd.addRowData(newRowId,{'data_group':dataGroup,'data_id':newRowId-1,'data_dsc':dataDsc,'data_type':dataType,'data_group_seq':dataGroupSeq,
                                'data_attr':dataAttr,'spec_chk_flg':specChkFlg,'u_spec':uSpec,
                                'l_spec':lSpec,'opi_data_flg':opiDataFlg,'spec_chk_typ':specChkTyp
                            },"before",rowId);
                        }else{
                            for(var i = 0 ; i < dataLength ; i++){
                                newRowId = getGridNewRowID(domObj.grids.$bisMItemListGrd);
                                if(lSpec!=""&&uSpec!=""){
                                    if(parseFloat(uSpec,10) < parseFloat(lSpec,10)){
                                        showErrorDialog("","参数的上限不能小于下限！");
                                        return false;
                                    }
                                }
                                domObj.grids.$bisMItemListGrd.addRowData(newRowId,
                                    {'data_group':dataGroup,'data_id':newRowId-1,'data_dsc':dataDsc,'data_type':dataType,'data_group_seq':dataGroupSeqMax +i+1,
                                        'data_attr':dataAttr,'spec_chk_flg':specChkFlg,'u_spec':uSpec,
                                        'l_spec':lSpec,'opi_data_flg':opiDataFlg,'spec_chk_typ':specChkTyp
                                    });
                            }
                        }
                        //默认选择新加的行
                        domObj.grids.$bisMItemListGrd.setSelection(newRowId, true);
                        $('#bisMItemDialog').modal("hide");
                        showSuccessDialog("新增item信息成功,点击保存确认！");
                    }else if (actionFlg =="U"){
                        var dataIds = domObj.grids.$bisMItemListGrd.jqGrid("getDataIDs");
                        var selRowId = domObj.grids.$bisMItemListGrd.jqGrid("getGridParam","selrow");
                        var rowData = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",selRowId);
                        var dataGroupSeq = domObj.$bisMItemDialog_dataGroupSeq.val();
                        for(var i = 0 ; i < dataIds.length ; i++){
                            var dataGroupS = domObj.grids.$bisMItemListGrd.jqGrid("getRowData",dataIds[i]);
                            if((dataGroupS.data_group === dataGroup) && (dataGroupS.data_group_seq === dataGroupSeq)
                                && (rowData.data_group_seq !== dataGroupSeq)){
                                showErrorDialog("","该参数组已存在相同组内顺序，请重新选择！");
                                return false;
                            }
                        }
                        //更新修改行的数据
                        selRowId = domObj.grids.$bisMItemListGrd.jqGrid("getGridParam","selrow");
                        if(lSpec!=""&&uSpec!=""){
                            if(parseFloat(uSpec,10) < parseFloat(lSpec,10)){
                                showErrorDialog("","参数的上限不能小于下限！");
                                return false;
                            }
                        }
                        domObj.grids.$bisMItemListGrd.setRowData(selRowId,
                            {'data_group':dataGroup,'data_id':selRowId-1,'data_dsc':dataDsc,'data_type':dataType,'data_group_seq':dataGroupSeq,
                                'data_attr':dataAttr,'spec_chk_flg':specChkFlg,'u_spec':uSpec,
                                'l_spec':lSpec,'opi_data_flg':opiDataFlg,'spec_chk_typ':specChkTyp
                            });
                        $('#bisMItemDialog').modal("hide");
                        showSuccessDialog("修改item信息成功,点击保存确认！");
                    }
                }

            };

            //将控件变成不可修改
            function unableFn() {
                domObj.$toolIdFk.attr(VAL.DISABLED_ATTR);
                domObj.$repUnit.attr(VAL.DISABLED_ATTR);
                domObj.$dataPat.attr(VAL.DISABLED_ATTR);
                domObj.$mesIdFk.attr(VAL.DISABLED_ATTR);
                // domObj.$mdlIdFk.attr(VAL.DISABLED_ATTR);
            }
            ;

            //将控件变成都可修改
            function enableFn() {
                domObj.$toolIdFk.attr(VAL.ENABLED_ATTR);
                domObj.$repUnit.attr(VAL.ENABLED_ATTR);
                domObj.$dataPat.attr(VAL.ENABLED_ATTR);
                domObj.$mesIdFk.attr(VAL.ENABLED_ATTR);
                // domObj.$mdlIdFk.attr(VAL.ENABLED_ATTR);
            };

            function isRepeat(arr) {
                var hash = {};
                for(var i in arr) {
                    if(hash[arr[i]])
                    {
                        return true;
                    }
                    // 不存在该元素，则赋值为true，可以赋任意值，相应的修改if判断条件即可
                    hash[arr[i]] = true;
                }
                return false;
            }



            //页面初始化函数
            function pageInit() {
                domObj.buttons.$query_btn.bind('click',
                    buttonFnc.queryFnc);

                domObj.buttons.$save_btn.bind('click',
                    buttonFnc.saveFnc);

                domObj.buttons.$add_btn.bind('click', buttonFnc.addFnc);
                domObj.buttons.$del_btn.bind('click', buttonFnc.delFnc);
                domObj.buttons.$clear_btn.bind('click',buttonFnc.clearFnc);
                domObj.buttons.$rollback_btn.bind('click',buttonFnc.rollback_func);
                domObj.buttons.$copy_btn.bind('click',buttonFnc.copy_func);
                //绑定ITEM
                domObj.buttons.$add_bisMItem_btn.bind('click',itemButtonFnc.itemAddFnc);
                domObj.buttons.$upd_bisMItem_btn.bind('click',itemButtonFnc.itemUpdateFnc);
                domObj.buttons.$del_bisMItem_btn.bind('click',itemButtonFnc.itemDeleteFnc);
                domObj.buttons.$insertbisMItem_btn.bind('click',insertItemFnc);

                //EXCEL操作
                domObj.buttons.$import_btn.click(function(){
                    buttonFnc.selectFileFunc();
                });
                domObj.buttons.$select_btn.change(function() {
                    buttonFnc.uploadFnc(this);
                });

                domObj.buttons.$download_btn.click(function(){
                    buttonFnc.downloadTempFun();
                });

                domObj.buttons.$export_btn.click(function(){
                    buttonFnc.exportFunc();
                });


                // $("input").attr(VAL.DISABLED_ATTR);
                $("select").attr(VAL.DISABLED_ATTR);
                $("input").val("");
                SelectDom.setSelect($("select"), "", "");
                unableFn();
                initBisMLabelList();
                initBisMItemList();
                //初始化4个下拉框
                initSelect();
            }
            ;

            /**
             * All controls's jquery object/text
             * @type {Object}
             */
            var domObjs = {
                W                   : $(window)                ,
                grids : {
                    $leftDiv         : $(".leftDiv"),
                    $rightDiv		 : $(".rightDiv"),
                    $bisMListDiv : $("#bisMListDiv"),
                    $bisMListGrd : $("#bisMListGrd"),
                    $bisMItemListDiv : $("#bisMItemListDiv"),
                    $bisMItemListGrd : $("#bisMItemListGrd")
                }
            };

            //enter
            document.onkeydown=function(event){
                var e = event || window.event || arguments.callee.caller.arguments[0];
                if(e && e.keyCode==13){ // 按 enter
               /*     $('.bootbox').modal("hide");*/
                    if($("#queryBisMDialog").css("display") == "block"){
                        queryDialog.queryFnc();
                    }
                }
            }

            //jqGrid表格自适应
            function resizeFnc(){
                var grdDivHeightL,grdDivHeightR,grdDivWidthL,grdDivWidthR;
                grdDivWidthL = domObjs.W.width() - 120 - domObjs.grids.$rightDiv.width();
                grdDivWidthR = domObjs.W.width() - 120 - domObjs.grids.$leftDiv.width();
                grdDivHeightL = domObjs.W.height() - domObjs.grids.$leftDiv.offset().top;
                grdDivHeightR = domObjs.W.height() - domObjs.grids.$rightDiv.offset().top;

                domObjs.grids.$leftDiv.height(grdDivHeightL);
                domObjs.grids.$bisMListDiv.width(grdDivWidthL);
                domObjs.grids.$bisMListDiv.height(grdDivHeightL*0.99 - 51);
                domObjs.grids.$bisMListGrd.setGridWidth(grdDivWidthL*0.99);
                domObjs.grids.$bisMListGrd.setGridHeight(grdDivHeightL*0.95 - 51 - 30);

                domObjs.grids.$rightDiv.height(grdDivHeightR);
                domObjs.grids.$bisMItemListDiv.width(grdDivWidthR);
                domObjs.grids.$bisMItemListDiv.height(grdDivHeightR*0.99 - 51 - 115);
                domObjs.grids.$bisMItemListGrd.setGridWidth(grdDivWidthR*0.99);
                domObjs.grids.$bisMItemListGrd.setGridHeight(grdDivHeightR*0.95 - 51 - 35 - 115);
            };
            resizeFnc();
            domObjs.W.resize(function() {
                resizeFnc();
            });
            //初始化界面
            pageInit();

            //初始化查询
            queryDialog.queryFnc();
        })
